﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;

namespace VinhSon.Intranet.Models
{
    public class Constant
    {
        public const string DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

        public static string CreateSalt()
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[32];
            rng.GetBytes(buff);
            return Convert.ToBase64String(buff);
        }

        public static string CreatePasswordHash(string password,
                                                string passwordSalt)
        {
            string saltAndPwd = String.Concat(password,
                                              passwordSalt);
            return FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd,
                                                                          "sha1");
        }
    }
}